package br.unicamp.ft.sahp.model.dao.impl;

import java.util.List;

import javax.persistence.EntityManagerFactory;
import javax.persistence.Query;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import br.unicamp.ft.sahp.model.dao.AbstractDAO;
import br.unicamp.ft.sahp.model.dao.NivelFormacaoDAO;
import br.unicamp.ft.sahp.model.entidades.NivelFormacao;

@Repository
public class NivelFormacaoDAOImpl extends AbstractDAO<NivelFormacao, Integer>
		implements NivelFormacaoDAO {

	@Autowired
	public NivelFormacaoDAOImpl(
			@Qualifier("entityManagerFactory") EntityManagerFactory factory) {
		super(factory, NivelFormacao.class);
	}
	
	public List<NivelFormacao> findAllNiveisFormacao() {
		String consulta = "SELECT nivelFormacao FROM NivelFormacao nivelFormacao ORDER BY nivelFormacao.id";
		Query query = getEntityManager().createQuery(consulta);
		return query.getResultList();
	}
}
